﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Pose
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;

#nullable disable
namespace UnityEngine
{
  /// <summary>
  ///   <para>Representation of a Position, and a Rotation in 3D Space</para>
  /// </summary>
  [Serializable]
  /// <summary>
  ///   <para>Creates a new pose with the given vector, and quaternion values.</para>
  /// </summary>
  /// <param name="position"></param>
  /// <param name="rotation"></param>
  public struct Pose(Vector3 position, Quaternion rotation) : IEquatable<Pose>
  {
    /// <summary>
    ///   <para>The position component of the pose.</para>
    /// </summary>
    public Vector3 position = position;
    /// <summary>
    ///   <para>The rotation component of the pose.</para>
    /// </summary>
    public Quaternion rotation = rotation;
    private static readonly Pose k_Identity = new Pose(Vector3.zero, Quaternion.identity);

    public override string ToString()
    {
      return UnityString.Format("({0}, {1})", (object) this.position.ToString(), (object) this.rotation.ToString());
    }

    public string ToString(string format)
    {
      return UnityString.Format("({0}, {1})", (object) this.position.ToString(format), (object) this.rotation.ToString(format));
    }

    /// <summary>
    ///   <para>Transforms the current pose into the local space of the provided pose.</para>
    /// </summary>
    /// <param name="lhs"></param>
    public Pose GetTransformedBy(Pose lhs)
    {
      return new Pose()
      {
        position = lhs.position + lhs.rotation * this.position,
        rotation = lhs.rotation * this.rotation
      };
    }

    /// <summary>
    ///   <para>Transforms the current pose into the local space of the provided pose.</para>
    /// </summary>
    /// <param name="lhs"></param>
    public Pose GetTransformedBy(Transform lhs)
    {
      return new Pose()
      {
        position = lhs.TransformPoint(this.position),
        rotation = lhs.rotation * this.rotation
      };
    }

    /// <summary>
    ///   <para>Returns the forward vector of the pose.</para>
    /// </summary>
    public Vector3 forward => this.rotation * Vector3.forward;

    /// <summary>
    ///   <para>Returns the right vector of the pose.</para>
    /// </summary>
    public Vector3 right => this.rotation * Vector3.right;

    /// <summary>
    ///   <para>Returns the up vector of the pose.</para>
    /// </summary>
    public Vector3 up => this.rotation * Vector3.up;

    /// <summary>
    ///   <para>Shorthand for pose which represents zero position, and an identity rotation.</para>
    /// </summary>
    public static Pose identity => Pose.k_Identity;

    public override bool Equals(object obj) => obj is Pose other && this.Equals(other);

    public bool Equals(Pose other)
    {
      return this.position == other.position && this.rotation == other.rotation;
    }

    public override int GetHashCode()
    {
      return this.position.GetHashCode() ^ this.rotation.GetHashCode() << 1;
    }

    public static bool operator ==(Pose a, Pose b) => a.Equals(b);

    public static bool operator !=(Pose a, Pose b) => !(a == b);
  }
}
